<include file='Base:header' />
	<style type="text/css">
		.hide{
			display: none;
		}
	</style>
	<body>
		<div class="submit">
			<h1 class="title">
				<a class="back" href="{:U('index')}">
					<img class="fl" src="__IMG__/back.png" style="margin-left: 5%;"/>
				</a>
				高管行程
				<a class="home" href="__APP__">
					<img class="fl" src="__IMG__/home_logo.png" style="margin-right: 5%;"/>
				</a>
			</h1>
		    <form action="{:U('')}" method='post' class='ajax-form'>
		    	
		        <div class="weui-cells">
		           <div class="weui-cell">
				        <div class="weui-cell__hd"><label for="name" class="weui-label">类型</label></div>
				        <div class="weui-cell__bd">
				          <input class="weui-input" id="schedule" name='' type="text" value="" readonly="" placeholder="请选择">
				          <input id="scheduleval" name='post[type]' type="hidden" value="" readonly="" placeholder="请选择">
				        </div>
				    </div>
		        </div>
				
		        <div class="weui-cells weui-cells_form">
		            <div class="weui-cell">
		                <div class="weui-cell__hd"><label class="weui-label">时间</label></div>
						<div class="weui-cell__bd ">
							<input type="text" data-toggle='date' id="calendar" name='post[date]' class="weui-input" placeholder="请选择时间 "/>
						</div>
		           </div>
		        </div>
				
		        
		        <div class="weui-cells__title hide">事由</div>
		        <div class="weui-cells hide">
		           <div class="weui-cell">
				        <div class="weui-cell__bd">
						    <textarea class="weui-textarea" placeholder="请输入外出事由（10个字以内）" rows="3" name='post[text]' onpropertychange="checkLength(this,10);" oninput="checkLength(this,10);"></textarea>
					    </div>
				    </div>
		        </div>
		      	<div class="sumbit_btn" style="padding-bottom: 30px;">
					<input type="button" class="weui-btn weui-btn_mini weui-btn_primary ajax-submit" style="margin: 0 auto;" value="提交">
				</div>
		    </form>
		</div>

		<include file='Base:footer' />
		<script type="text/javascript">
			
			function GetArgsFromHref(sHref, sArgName){
			      var args    = sHref.split("?");
			      var retval = "";
			    
			      if(args[0] == sHref) /*参数为空*/
			      {
			           return retval; /*无需做任何处理*/
			      }  
			      var str = args[1];
			      args = str.split("&");
			      for(var i = 0; i < args.length; i ++)
			      {
			          str = args[i];
			          var arg = str.split("=");
			          if(arg.length <= 1) continue;
			          if(arg[0] == sArgName) retval = arg[1]; 
			      }
			      return retval;
			}
			
			var now_data = GetArgsFromHref(window.location.href,'data');
			
			//设置时间选择器
			
			//当前时间
			var time = new Date();
			var now_y = time.getFullYear();
			var now_m = time.getMonth()+1;
			var now_d = time.getDate();
			var min_y = time.getFullYear()-1;
			var max_y = time.getFullYear()+1;
			var buling = function(a){
				if(a<10){
					return "0" + a;
				}else{
					return a;
				}
			}
			now_m = buling(now_m);
			now_d= buling(now_d);
			var min_day = min_y + "-01-01";
			var max_day = max_y + "-"+now_m+"-"+now_d;
			
			$("#starttime").datetimePicker({
				yearSplit: "-",
				monthSplit: "-",
				dateSplit: "",
				min: min_day,
				max: max_day,
			});
			
			
			//类型
			$("#schedule").select({
			  	title: "选择请假类型",
			    items: [
			    	{
			    		title:'在岗',
			    		value: '1',
			    	},
			    	{
			    		title:'短途外出',
			    		value: '2'
			    	},
			    	{
			    		title:'长途出差',
			    		value: '3'
			    	},
			    	{
			    		title:'请假',
			    		value: '4'
			    	}
			    ],
			    onChange:function(e){
			    	var select_value = $("#schedule").attr("data-values");
					if(select_value == "2" || select_value == "3" || select_value == "4"){
						$(".hide").show();
					}else if(select_value == "1"){
						$(".hide").hide();
					}
					$("#scheduleval").val(select_value)
			    }
			});
			$("#calendar").calendar({
				minDate: [min_day],
				maxDate: [max_day],
//				dateFormat: 'yyyy年mm月dd日',
			});
			
			$("#calendar").attr("value",now_data)
			
			//字数限制
			function checkLength(obj, maxlength) {
				if(obj.value.length > maxlength) {
					obj.value = obj.value.substring(0, maxlength);
				}
			}
		</script>
	</body>
</html>